//常量
var oldSysUserStatus;

//加载页面
$(document).ready(function () {
    var sysUserId = $("#sysUserId").val();
    $.ajax({
               url: webConfig.webUrl + '/getSysUserById',
               type: 'POST',
               dataType: 'json',
               data: {sysUserId: sysUserId}
           })
        .done(function (data) {
            if (data) {
                if (data.code == "10000" && data.result) {
                    $("#sysUserName").val(data.result.userName);
                }
            }
        });
});

//提交
$('#btnUpdate').click(function () {

    if ($("#checkPassword").val() != $("#newPassword").val()) {
        alert("两次输入密码不相同！");
        return false;
    }


    $.ajax({
               url: webConfig.webUrl + '/updatePassword',
               type: 'POST',
               dataType: 'json',
               data: {
                   sysUserId: $("#sysUserId").val(),
                   oldPassword: $("#oldPassword").val(),
                   newPassword: $("#newPassword").val()
               },
               success: function (data) {
                   if (data) {
                       if (data.code == "10000") {
                           layer.alert(data.message, {icon: 1}, function () {
                               parent.layer.closeAll('iframe');
                           });
                           return;
                       } else {
                           layer.alert(data.message, {icon: 2});
                       }
                   }
               }
           });

    // $.ajax({
    //            url: url,
    //            type: 'POST',
    //            dataType: 'json',
    //            contentType: "application/json; charset=utf-8",
    //            data: {"sysUserId": sysUserId,"oldPassword": oldPassword,"newPassword":
    // newPassword} }) .done(function (data) { if (data) { if (data.code == "10000") {
    // layer.alert(data.message, {icon: 1}, function () { parent.layer.closeAll('iframe'); });
    // return; } else { layer.alert(data.message, {icon: 2}); } } });
});

//取消
$('#btnCancel').click(function () {
    parent.layer.closeAll('iframe');
});
